package com.lshtv.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.lshtv.base.PageList;
import com.lshtv.base.WorkQuery;
import com.lshtv.model.Work;
import com.lshtv.service.WorkQueryFacade;

/**
 * 首页，指向默认首页页面
 * intro
 * @author danjingyu
 * @version $Id: IndexController.java, v 0.1 2013-5-11 下午4:55:15 danjingyu Exp $
 */
@Controller
@RequestMapping("/index.htm")
public class IndexController {
    //private Logger          logger = Logger.getLogger(IndexController.class);
    @Autowired
    private WorkQueryFacade workQueryFacade;

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView handleRequest(HttpServletRequest httpservletrequest,
                                      HttpServletResponse httpservletresponse, ModelMap modelMap)
                                                                                                 throws Exception {
        ModelAndView view = new ModelAndView("home/index");
        modelMap.put("works", workQueryFacade.queryTop());
        return view;
    }

    public void setWorkQueryFacade(WorkQueryFacade workQueryFacade) {
        this.workQueryFacade = workQueryFacade;
    }

}
